package File;

import java.io.BufferedReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;

public class WriterFile {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		String str;
		FileWriter fw;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try{
			fw = new FileWriter("data.txt");
		}catch(IOException ex){
			System.out.println("Khong tim thay file.");
			return;
		}
		
		System.out.println("Hay nhap vao mot chuoi ky tu ket thu bang 'stop'");
		do{
			System.out.print(":");
			str = br.readLine();
			if(str.compareTo("stop") == 0)
				break;
			str = str + "\n";
			fw.write(str);
		}while(str.compareTo("stop") != 0);
		System.out.println("thanh cong roi ban ah");
		fw.close();
	}

}
